package org.linlinjava.litemall.wx.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Description: TODO
 * @author: Destin
 * @date: 2021-10-13
 */
public class KeywordUtil {

    public static String IgnoreCaseReplace(String source, String patternStr) {
        Pattern p = Pattern.compile(patternStr, Pattern.CASE_INSENSITIVE);
        Matcher mc = p.matcher(source);
        StringBuffer sb = new StringBuffer();
        while (mc.find()) {
            mc.appendReplacement(sb, "<font color='red' >" + mc.group() + "</font>");
        }
        mc.appendTail(sb);
        return sb.toString();
    }
}
